package com.veo.controller;

import com.veo.entity.Employee;
import com.veo.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class EmployeeController {

    @Autowired
    private EmployeeService service;

    @GetMapping("/emp/{id}")
    public Employee getEmp(@PathVariable("id")Integer id){
        return service.getEmp(id);
    }

    @GetMapping("/emp")
    public Employee updateEmp(Employee employee){
        service.updateEmp(employee);
        return employee;
    }

    @GetMapping("/delemp/{id}")
    public String delEmp(@PathVariable("id") Integer id){
        service.delEmpById(id);
        return "success";
    }

    @GetMapping("/insertemp")
    public String insertEmp(Employee employee){
        service.insertEmp(employee);
        return "success";
    }



    @GetMapping("/emp/lastName/{lastName}")
    public Employee seleByLastName(@PathVariable("lastName") String lastName){
        return service.selByLastName(lastName);
    }
}
